<template>
	<view class="container">
		<view class="lists">
			<!-- <view v-if="datas.length == 0">
				<emptyPage :title="$t(`暂无模板~`)"></emptyPage>
			</view>
			<!-- <view class="item" v-for="n in datas"> -->
			<view v-if="datas.length == 0">
				<emptyPage :title="$t(`暂无模板~`)"></emptyPage>
			</view>
			<view class="item" v-for="n in datas" @click="gotoDetail(n)"  @longpress="delEvent(n.id)">
				<view class="name">{{n.name}}</view>
			</view><!--item end-->
			
		</view><!--lists end-->
		<view class="footer">
			<view class="submit-btn" @click="gotoTemp()">添加项目</view>
		</view>
	</view>
</template>

<script>
	import {tecer_items_list} from "@/api/platform.js";
	import emptyPage from '@/components/emptyPage';
	export default {
		components: {
			emptyPage
		},
		data() {
			return {
				datas:[],
				operationing:false
			}
		},
		onLoad(options) {
		},
		onShow() {
			this.getData();
		},
		methods: {
			gotoDetail(n){
				uni.navigateTo({
					url:'/pages/users/tecer/project/add?id='+n.id+'&name='+n.name+"&remark="+n.remark
				})
			},
			gotoAdd(){
				uni.navigateTo({
					url:'/pages/users/tecer/project/add'
				})
			},
			getData(){
				let that = this;
				uni.showLoading({
					title:'加载中...'
				});
				tecer_items_list({}).then((res) => {
					let data = res.data;
					 console.info(data);
					 that.datas = data.list;
					uni.hideLoading();
				});
			},
			delEvent(id){
				if(this.operationing){
					return;
				}
				
				let that = this;
				uni.showModal({
				    title: '提示',
				    content: '确定删除？',
				    success: function (res) {
				        if (res.confirm) {
							that.operationing = true;
							uni.showLoading({
								title: '正在处理',
							})
							del_call_record(id).then(res => {;
								console.info(res.data)
								that.operationing = false;
								uni.hideLoading();
								if(res.status == 200){
									that.getData();
									uni.showToast({
										icon:'success',
										title:res.msg
									})
								}else{
									uni.showToast({
										icon:'error',
										title:res.msg
									})
								}
							}).catch(err => {
								that.operationing = false;
								uni.hideLoading();
								return that.$util.Tips({
									title: err
								})
							});
				        }//end if
				    }//end success method
				});
			}
		}
	}
</script>

<style scoped lang="scss">
	page{
		background-color: #f2f2f2;
	}
	.container{
		display: flex;
		flex-direction: column;
		.lists{
			display: flex;
			flex-direction: column;
			padding-bottom: 0;  
			padding-bottom: constant(safe-area-inset-bottom);  
			padding-bottom: env(safe-area-inset-bottom); 
			margin-bottom: 100rpx;
			.item{
				display: flex;
				flex-direction: row;
				align-items: center;
				background-color: white;
				margin: 20rpx 30rpx 0rpx 30rpx;
				padding: 20rpx;
				.name{
					margin-top: 10rpx;
					font-size: 28rpx;
					color: gray;
				}
			}//item end
		}//lists end
		.footer{
			height: 80rpx;
			width: 100%;
			position: fixed;
			right: 0;
			bottom: 0;
			left: 0;
			display: flex;
			flex-direction: row;
			align-items: center;
			justify-content: center;
			padding-bottom: 0;  
			padding-bottom: constant(safe-area-inset-bottom);  
			padding-bottom: env(safe-area-inset-bottom); 
			.submit-btn{
				background-color: $uni-main-color;
				color: white;
				font-size: 28rpx;
				height: 80rpx;
				width: 100%;
				text-align: center;
				line-height: 80rpx;
			}
		}
	}
	
</style>
